import Page
from Page import Service
from Base.Base import Base
from selenium.webdriver.common.by import By


class ServicePhonePage(Base):
    """
    电话页面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.phone_home_btn = (By.XPATH, Service.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.phone_back_btn = (By.XPATH, Service.RESOURCE_ID.format('ivBack'))

        # 门店电话
        self.phone_confirm_dialog_title_text = (By.XPATH, Service.RESOURCE_ID.format("confirm_dialog_title"))

        # 电话内容
        self.phone_confirm_dialog_content_text = (By.XPATH, Service.RESOURCE_ID.format("confirm_dialog_content"))

        # 确认按钮
        self.phone_sure_btn = (By.XPATH, Service.RESOURCE_ID.format("btn_confirm_sure"))

        # 取消按钮
        self.phone_cancel_btn = (By.XPATH, Service.RESOURCE_ID.format("btn_confirm_cancel"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.phone_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.phone_back_btn)

    def get_confirm_dialog_title_(self):
        """
        获取门店电话

        :return: 获取元素
        """
        return self.find_element_o(self.phone_confirm_dialog_title_text)

    def get_confirm_dialog_content(self):
        """
        获取电话内容

        :return: 获取元素
        """
        return self.find_element_o(self.phone_confirm_dialog_content_text)

    def click_sure(self):
        """
        点击确认按钮

        :return: None
        """
        self.click_element(self.phone_sure_btn)

    def click_cancel(self):
        """
        点击取消按钮

        :return: None
        """
        self.click_element(self.phone_cancel_btn)

    def is_display_service_phone(self):
        """
        是否进入电话页

        :return: bool
        """
        return self.is_display(self.phone_confirm_dialog_title_text)
